/**
 * Created by IntelliJ IDEA.
 * User: Liu Yuhong
 * Date: 12-10-25
 * Time: 下午5:05
 * Subpage tender page functions.
 */

$(function() {
	var selfServiceStd = [
	                      {
							 'itemId': "menuItem0",
							 'itemName': getLanMsg("0ec22410-000067"),
							 'needShow':true,
							 "itemUrl": "/ebvp/selfinfo/password?menuid=41"
						  },
	                      {
	                          'itemId': "menuItem1",
	                          'itemName': getLanMsg("0ec22410-000068"),
	                          'needShow':bModuleSRM,
	                          "itemUrl": "/ebvp/selfinfo/userinfo?menuid=42"
	                      },
	                      {
	                          'itemId': "menuItem2",
	                          'itemName': getLanMsg("0ec22410-000069"),
	                          'needShow':bModuleSRM,
	                          "itemUrl": "/ebvp/selfinfo/editinfo?menuid=43"
	                      },
	                      {
	                          'itemId': "menuItem3",
	                          'itemName': getLanMsg("0ec22410-000070"),
	                          'needShow':bModuleSRM,
	                          "itemUrl": "/ebvp/selfinfo/contractlist?menuid=46"
	                      },
	                      {
	                          'itemId': "menuItem4",
	                          'itemName': getLanMsg("0ec22410-000071"),
	                          'needShow':bModuleEBP,
	                          "itemUrl": "/ebvp/prodprice/prodpricelist?menuid=47"
	                      },
	                      {
	                          'itemId': "menuItem5",
	                          'itemName': getLanMsg("0ec22410-000072"),
	                          'needShow':bModuleEBP,
	                          "itemUrl": "/ebvp/infopub/viewfile?menuid=48"
	                      }
	                  ];
	
	var selfServiceGh = [
        {
            'itemId': "menuItem0",
            'itemName': getLanMsg("0ec22410-000067"),
            'needShow':true,
            "itemUrl": ".",
            'callback': function() { window.open("https://chinajvs.towngas.com.cn/iisadmpwd/aexp2b.asp"); return false; }  //港华修改密码的地址
        },
        {
            'itemId': "menuItem1",
            'itemName': getLanMsg("0ec22410-000068"),
            'needShow':bModuleSRM,
            "itemUrl": "/ebvp/selfinfo/userinfo?menuid=42"
        },
        {
            'itemId': "menuItem2",
            'itemName': getLanMsg("0ec22410-000069"),
            'needShow':bModuleSRM,
            "itemUrl": "/ebvp/selfinfo/editinfo?menuid=43"
        },
        {
            'itemId': "menuItem3",
            'itemName': getLanMsg("0ec22410-000070"),
            'needShow':bModuleSRM,
            "itemUrl": "/ebvp/selfinfo/contractlist?menuid=46"
        },
        {
            'itemId': "menuItem4",
            'itemName': getLanMsg("0ec22410-000071"),
            'needShow':bModuleEBP,
            "itemUrl": "/ebvp/prodprice/prodpricelist?menuid=47"
        },
        {
            'itemId': "menuItem5",
            'itemName': getLanMsg("0ec22410-000072"),
            'needShow':bModuleEBP,
            "itemUrl": "/ebvp/infopub/viewfile?menuid=48"
        }
    ];
	
	if(bStdVersion){
		$( "#selfService" ).UIDropMenu({ "menuId": "selfServiceMenu", 'items': selfServiceStd, 'alignRight': true });
	}else{
		$( "#selfService" ).UIDropMenu({ "menuId": "selfServiceMenu", 'items': selfServiceGh, 'alignRight': true });
	}
	
    var signedIn = [
        {
            'itemId': "nav0",
            'itemName': getLanMsg("0ec22400-000012"),
            'needShow': "true",
            'itemUrl': "/ebvp/infopub/pubmain"
        },
        {
            'itemId': "nav1",
            'itemName': getLanMsg("0ec22400-000013"),
            'itemUrl': ".",
            'needShow': bModuleEBP,
            'callback': function() {
        		return false;
        	},
            'subMenu': [
                {
                    'itemId': "nav1menuItem0",
                    'itemName': getLanMsg("0ec22400-000014"),
            		'needShow': bModuleEBP,
                    "itemUrl": "/ebvp/sourcing/biddingprojlist?menuid=21"
                },
                {
                    'itemId': "nav1menuItem1",
                    'itemName': getLanMsg("0ec22400-000015"),
            		'needShow': bModuleEBP,
                    "itemUrl": "/ebvp/sourcing/badeprojlist?menuid=22"
                }
            ]
        },
        {
            'itemId': "nav2",
            'itemName': getLanMsg("0ec22400-000016"),
            'itemUrl': ".",
            'needShow': bModuleEBPOrSCM_CT,
            'subMenu': [
                {
                    'itemId': "nav2menuItem0",
                    'itemName': getLanMsg("0ec22400-000017"),
            		'needShow': bModuleEBPOrSCM_CT && bStdVersion,
                    "itemUrl": "/ebvp/contract/contractconfirm?menuid=38"
                },
                {
                    'itemId': "nav2menuItem1",
                    'itemName': getLanMsg("0ec22400-000018"),
            		'needShow': bModuleEBPOrSCM_CT,
                    "itemUrl": "/ebvp/contract/contractlist?menuid=34"
                },
                {
                    'itemId': "nav2menuItem2",
                    'itemName': getLanMsg("0ec22400-000019"),
            		'needShow': bModuleEBP && bStdVersion,
                    "itemUrl": "/ebvp/contractprice/ctreptlist?menuid=35"
                },
                {
                    'itemId': "nav2menuItem3",
                    'itemName': getLanMsg("0ec22400-000188"),
                    'needShow': bModuleEBP && bModuleSCM_CT,
                    "itemUrl": "/ebvp/contract/initCtPriceAd"
                },
                {
                    'itemId': "nav2menuItem4",
                    'itemName': getLanMsg("0ec22400-000189"),
                    'needShow': bModuleEBP && bModuleSCM_CT,
                    "itemUrl": "/ebvp/contract/initCtPrice"
                }
            ]
            ,
            'callback': function() {
        		return false;
        	}
        },
        {
            'itemId': "nav3",
            'itemName': getLanMsg("0ec22400-000020"),
            'itemUrl': ".",
            'needShow': bModuleEBPOrSCM_PU,
            'subMenu': [
                {
                    'itemId': "nav3menuItem0",
                    'itemName': getLanMsg("0ec22400-000021"),
            		'needShow': bModuleEBPOrSCM_PU,
                    "itemUrl": "/ebvp/order/confirmlist?menuid=31"
                },
                {
                    'itemId': "nav3menuItem1",
                    'itemName': getLanMsg("0ec22400-000022"),
            		'needShow': bModuleSCM_PU && bStdVersion,
                    "itemUrl": "/ebvp/order/exestatuslist?menuid=32"
                },
                {
                    'itemId': "nav3menuItem2",
                    'itemName': getLanMsg("0ec22400-000023"),
            		'needShow': bModuleSCM_PU,
                    "itemUrl": "/ebvp/order/exeinfolist?menuid=33"
                }
            ]
            ,
            'callback': function() {
        		return false;
        	}
        },
        {
            'itemId': "nav4",
            'itemName': getLanMsg("0ec22400-000024"),
            'itemUrl': ".",
            'needShow': bModuleEBVSCOrSCM_PU,
            'subMenu': [
                {
                    'itemId': "nav4menuItem0",
                    'itemName': getLanMsg("0ec22400-000025"),
           	 		'needShow': bModuleSCM_PU,
                    "itemUrl": "/ebvp/other/goQryPageFromList?menuid=36"
                },
                {
                    'itemId': "nav4menuItem1",
                    'itemName': getLanMsg("0ec22400-000026"),
           	 		'needShow': bModuleSCM_PU,
                    "itemUrl": "/ebvp/other/sendPlanList?menuid=37"
                }
                ,
                {
                    'itemId': "nav4menuItem2",
                    'itemName': getLanMsg("0ec22400-000027"),
           	 		'needShow': bModuleSCM_PU,
                    "itemUrl": "/ebvp/other/sendNoticeList"
                },
                {
                    'itemId': "nav4menuItem3",
                    'itemName': getLanMsg("0ec22400-000028"),
           	 		'needShow': bModuleEBVSC,
                    "itemUrl": "/ebvp/schedulecoll/paichengconller/scheduleconfirm"
                },
                {
                      'itemId': "nav4menuItem4",
                      'itemName': getLanMsg("0ec22400-000190"),
                      'needShow': bModuleEBVSC,
                      "itemUrl": "/ebvp/schedulecoll/scheduleDetail"
                },
                {
                      'itemId': "nav4menuItem5",
                      'itemName': getLanMsg("0ec22400-000191"),
                      'needShow': bModuleEBVSC,
                      "itemUrl": "/ebvp/schedulecoll/scheHisProdCount"
                },
                {
                      'itemId': "nav4menuItem6",
                      'itemName': getLanMsg("0ec22400-000192"),
                      'needShow': bModuleEBVSC,
                      "itemUrl": "/ebvp/schedulecoll/scheHistoryDetail"
                }
            ]
            ,
            'callback': function() {
        		return false;
        	}
        },
        {
            'itemId': "nav5",
            'itemName': getLanMsg("0ec22400-000029"),
            'itemUrl': ".",
            'needShow': bModuleSCM_IC,
            'subMenu': [
                {
                    'itemId': "nav5menuItem0",
                    'itemName': getLanMsg("0ec22400-000030"),
           	 		'needShow': bModuleSCM_IC_SYS,
                    "itemUrl": "/ebvp/other/nowStorageList"
                },
                {
                    'itemId': "nav5menuItem1",
                    'itemName': getLanMsg("0ec22400-000031"),
           	 		'needShow': bModuleSCM_PU && bModuleSCM_IC_EBP_SYS && bStdVersion,
                    "itemUrl": "/ebvp/other/addGoodsApplyList"
                },
                {
                    'itemId': "nav5menuItem2",
                    'itemName': getLanMsg("0ec22400-000032"),
           	 		'needShow': bModuleSCM_IC_SYS,
                    "itemUrl": "/ebvp/other/useCountList"
                },
                {
                    'itemId': "nav5menuItem3",
                    'itemName': getLanMsg("0ec22400-000033"),
           	 		'needShow': bModuleSCM_IC,
                    "itemUrl": "/ebvp/other/arrGoodsList?menuid=52"
                },
                {
                    'itemId': "nav5menuItem4",
                    'itemName': getLanMsg("0ec22400-000034"),
           	 		'needShow': bModuleSCM_IC,
                    "itemUrl": "/ebvp/other/storageList?menuid=53"
                },
                {
                    'itemId': "nav5menuItem5",
                    'itemName': getLanMsg("0ec22400-000035"),
           	 		'needShow': bModuleSCM_IC,
                    "itemUrl": "/ebvp/other/supInfoList?menuid=51"
                },
                {
                    'itemId': "nav5menuItem6",
                    'itemName': getLanMsg("0ec22400-000036"),
           	 		'needShow': bModuleSCM_IC_SYS,
                    "itemUrl": "/ebvp/other/backGoodsHandlerList"
                }
            ]
            ,
            'callback': function() {
        		return false;
        	}
        },
        {
            'itemId': "nav6",
            'itemName': getLanMsg("0ec22400-000037"),
            'itemUrl': ".",
           	 'needShow': bModuleARAPOrSCM_PU,
            'subMenu': [
                {
                    'itemId': "nav6menuItem0",
                    'itemName': getLanMsg("0ec22400-000038"),
           	 		'needShow': bModuleSCM_PU,
                    "itemUrl": "/ebvp/other/invoiceList?menuid=54"
                },
                {
                    'itemId': "nav6menuItem1",
                    'itemName': getLanMsg("0ec22400-000039"),
           	 		'needShow': bModuleARAP && bStdVersion,
                    "itemUrl": "/ebvp/other/paymentList?menuid=55"
                }
            ]
            ,
            'callback': function() {
        		return false;
        	}
        },
        {
    		'itemId' : "nav7",
    		'itemName' : "投诉与建议",
    		'needShow' : bModuleARAPOrSCM_PU,
    		'itemUrl' : ".",
    		'subMenu' : [ {
    			'itemId' : "nav7menuItem0",
    			'itemName' : "投诉响应",
    			'needShow' : bModuleSCM_PU,
    			"itemUrl" : "/ebvp/advorappcoll/appealrespcompl?complainoradvis=1"
    		}, {
    			'itemId' : "nav7menuItem1",
    			'itemName' : "建议响应",
    			'needShow' : bModuleSCM_PU,
    			"itemUrl" : "/ebvp/advorappcoll/appealrespcompl?complainoradvis=0"
    		} ],
    		'callback' : function() {
    			return false;
    		}
    	}
    ];
    /* 导航栏及下拉菜单 */
    $( "#signedInNavigatorBar" ).UINavigator({ 'items': signedIn, 'current': 2 });

	// 设置导航菜单状态。
	var config = {
		// 首页
		"nav0" : [ "pubmain", "infopub" ],
		// 投标
		"nav1" : [ "sourcing" ],
		// 合同
		"nav2" : [ "contract" ],
		// 订单
		"nav3" : [ "order" ],
		// 发货排程
		"nav4" : [ "goQryPageFromList", "sendNoticeList", "qrySendNotice",
				"qrySendNoticeDetail", "exportSendNotice", "goToAddPage",
				"goQryPageFromList", "goQryPageFromAdd", "addQryData2NewPage",
				"saveMySendPlan", "deleteSendNotice", "cmtMySendPlan",
				"goback2AddPage", "goback2List", "goBack2SenNoticeList",
				"sendPlanList", "qrySendPlan", "sendPlanSave",
				"exportSendPlan", "schedulecoll" ],
		// 库存不用配置，不配置的全部为库存
		// 结算
		"nav6" : [ "invoiceList", "qryInvoiceList", "exportInvoice",
				"invoiceDetail", "goBack2Invoice", "paymentList",
				"qryPaymentList", "exportPayment", "paymentDetail",
				"goBack2Payment" ]

	};
	// 根据url来判断是哪个模块
	var url = window.location.href;
	var hit = false;
	for ( var module in config) {
		var pages = config[module];
		for ( var i = 0; i < pages.length; i++) {
			if (url.indexOf(pages[i]) != -1) {
				$("#" + module).addClass("focus");
				hit = true;
				break;
			}
		}
	}
	// 如果不在配置中则全部为【库存】nav5
	if (!hit) {
		$("#nav5").addClass("focus");
	}

    var menuGroups = [
        {
            'menuId': "tenderMenu",
            'menuTitle': getLanMsg("0ec22400-000016"),
            'iconImg': null,
            'needShow': bModuleEBPOrSCM_CT,
            'items': [               
                {
                    'itemId': "tenderMenuItem0",                  
                    "itemUrl": ".",
                    'itemName': getLanMsg("0ec22400-000017"),
                    'needShow': bModuleEBPOrSCM_CT && bStdVersion,
                    'callback': function() {window.location = ebvp_context + "/contract/contractconfirm?menuid=38";  return false; }
                },
                {
                    'itemId': "tenderMenuItem1",                  
                    "itemUrl": ".",
                    'itemName': getLanMsg("0ec22400-000018"),
                    'needShow': bModuleEBPOrSCM_CT,
                    'callback': function() {window.location = ebvp_context + "/contract/contractlist?menuid=34";  return false;} 
                },
                {
                    'itemId': "tenderMenuItem2",                   
                    "itemUrl": ".",
                    'itemName': getLanMsg("0ec22400-000019"),
                    'needShow': bModuleEBP && bStdVersion,          
                    'callback': function() {window.location = ebvp_context + "/contractprice/ctreptlist?menuid=35";  return false;}  
                },
                {
                    'itemId': "tenderMenuItem3",
                    "itemUrl": ".",
                    'itemName': getLanMsg("0ec22400-000188"),
                    'needShow': bModuleEBPOrSCM_CT,
                    'callback': function() {window.location = ebvp_context + "/contract/initCtPriceAd";  return false;}         
                },
                {
                    'itemId': "tenderMenuItem4",
                    "itemUrl": ".",
                    'itemName': getLanMsg("0ec22400-000189"),
                    'needShow': bModuleEBPOrSCM_CT,
                    'callback': function() {window.location = ebvp_context + "/contract/initCtPrice";  return false;}                  
                } 
            ]                         
        }
    ];
    
     /* 左侧菜单栏 */
    $( "#columnLeft" ).UIColumnMenu({
        'menuGroups': menuGroups,
        'menuHeight': 600,
        'singleGroup': true
    });
  
    $(function() {	
    	if(t==1){
			$( "#tenderMenuItem0" ).parents("ul").find(".current").removeClass("current");
			$( "#tenderMenuItem0" ).addClass("current");
    	}
    	if(t==2){
    		$( "#tenderMenuItem1" ).parents("ul").find(".current").removeClass("current");
    		$( "#tenderMenuItem1" ).addClass("current");
    	}
    	if(t==3){
    		$( "#tenderMenuItem2" ).parents("ul").find(".current").removeClass("current");
    		$( "#tenderMenuItem2" ).addClass("current");
    	}
    	if(t==4){
    		$( "#tenderMenuItem3" ).parents("ul").find(".current").removeClass("current");
    		$( "#tenderMenuItem3" ).addClass("current");
    	}
    	if(t==5){
    		$( "#tenderMenuItem4" ).parents("ul").find(".current").removeClass("current");
    		$( "#tenderMenuItem4" ).addClass("current");
    	}
	 });
    
   
   
});
